package com.liqi.display.service.impl;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import com.liqi.display.entity.returnType.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.liqi.display.common.Constants;
import com.liqi.display.entity.SystemParam;
import com.liqi.display.mapper.QueueMapper;
import com.liqi.display.mapper.StatisticsMapper;
import com.liqi.display.service.DeviceService;
import com.liqi.display.service.IStatisticsService;
import com.liqi.display.service.ISystemParamService;
import com.liqi.display.utils.CalculateUtil;
import com.liqi.display.utils.DateUtil;

import static io.netty.util.internal.SystemPropertyUtil.contains;

/**
 * <p>
 *  大屏统计
 * </p>
 *
 * @author yhh
 * @since 2022-05-27
 */
@Service
public class StatisticsServiceImpl implements IStatisticsService {

    private Logger logger = LoggerFactory.getLogger(StatisticsServiceImpl.class);

    @Autowired
    private QueueMapper queueMapper;



    @Autowired
    private StatisticsMapper statisticsMapper;

    @Autowired
    private ISystemParamService systemParamService;

    @Autowired
    private DeviceService deviceService;


    /**
     * 1.当天业务量统计分析
     * @return
     */
    //当天预约数
    @Override
    @DS("hqueue")
    public Integer getOrderDayTotal( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getOrderDayTotal(start,end);
        } else {
            return queueMapper.getOrderDayTotal(start,end);
        }
    }
    //1.1 当天取号总数
    @Override
    @DS("hqueue")
    public Integer getNumDayTotal( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getNumDayTotal(start,end);
        } else {
            return queueMapper.getNumDayTotal(start,end);
        }
    }
    //1.2 当天现场取号数
    @Override
    @DS("hqueue")
    public Integer getXCNumDayTotal( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getXCNumDayTotal(start,end);
        } else {
            return queueMapper.getXCNumDayTotal(start,end);
        }
    }
    //1.3 当天微信取号数
    @Override
    @DS("hqueue")
    public Integer getWXNumDayTotal( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getWXNumDayTotal(start,end);
        } else {
            return queueMapper.getWXNumDayTotal(start,end);
        }
    }
    //1.4 当天预约取号数
    @Override
    @DS("hqueue")
    public Integer getYYNumDayTotal( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getYYNumDayTotal(start,end);
        } else {
            return queueMapper.getYYNumDayTotal(start,end);
        }
    }
    //1.5 当天收件总数
    @Override
    @DS("hqueue")
    public Integer getTotalDeal( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getTotalDeal1(start,end);
        } else {
            return queueMapper.getTotalDeal1(start,end);
        }
    }
    //1.6 当天发证总数
    @Override
    @DS("hqueue")
    public Integer getTotalSend(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            //return queueMapper.getTotalSend(start,end);
            //return 0;
            return queueMapper.getMouthTotalSendByComName(start,end);
        } else {
            //return queueMapper.getTotalSend(start,end);
            //return 0;
            return queueMapper.getMouthTotalSendByComName(start,end);
        }
    }
    //1.7 已经办结
    @Override
    @DS("hqueue")
    public Integer getTotalComplete( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getTotalComplete(start,end);
        } else {
            return queueMapper.getTotalComplete(start,end);
        }
    }
    //1.8 正在办理
    @Override
    @DS("hqueue")
    public Integer getTotalDoing( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getTotalDoing(start,end);
        } else {
            return queueMapper.getTotalDoing(start,end);
        }
    }
    //1.9 当前等待
    @Override
    @DS("hqueue")
    public Integer getTotalWaiting( String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getTotalWaiting(start,end);
        } else {
            return queueMapper.getTotalWaiting(start,end);
        }
    }

    //2.当天平均等待受理时间 平均等待时间(分)、平均受理时间(分)
    /**
     * 2.1 获取平均等待时间
     * @return
     */
    @Override
    @DS("hqueue")
    public Double getWaitTime(Date start, Date end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            Double waitTime =  Math.random()*10;
            BigDecimal bg = new BigDecimal(waitTime);
            Double resultDouble = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return null;
        } else {
            return queueMapper.getWaitTime(start, end);
        }
    }
    /**
     * 2.2 获取平均受理时间
     * @return
     */
    @Override
    @DS("hqueue")
    public Double getAccessTime(Date start, Date end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            Double accessTime =  Math.random()*10;
            BigDecimal bg = new BigDecimal(accessTime);
            Double resultDouble = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return null;
        } else {
            return queueMapper.getAccessTime(start,end);
        }
    }

    //3.当天的各时段取号量
    //3.1 当天的每个时间段
    @Override
    @DS("hqueue")
    public int lateComare(Date date, Integer num) {
        String formateDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        if (num == 9) {
            return queueMapper.lateComare(formateDate,"09:30:00","10:30:00");
        } else if (num == 10) {
            return queueMapper.lateComare(formateDate,"10:30:00","11:30:00");
        } else if (num == 11) {
            return queueMapper.lateComare(formateDate,"11:30:00","12:00:00");
        } else if (num == 14) {
            return queueMapper.lateComare(formateDate,"14:30:00","15:30:00");
        } else if (num == 15) {
            return queueMapper.lateComare(formateDate,"15:30:00","16:30:00");
        } else if (num == 16) {
            return queueMapper.lateComare(formateDate,"16:30:00" , "17:30:00");
        } else {
            return queueMapper.lateComare(formateDate,"08:00:00", "09:30:00");
        }
    }
    //3.2 上星期的同一天
    @Override
    public int lateComareHistory(Date startDate, Date endDate, Integer num) {
        String formateStartDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startDate);
        String formateEndDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDate);
        if (num == 9) {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"09:30:00","10:30:00");
        } else if (num == 10) {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"10:30:00","11:30:00");
        } else if (num == 11) {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"11:30:00","12:00:00");
        } else if (num == 14) {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"14:30:00","15:30:00");
        } else if (num == 15) {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"15:30:00","16:30:00");
        } else if (num == 16) {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"16:30:00" , "17:30:00");
        } else {
            return queueMapper.lateComareHistory(formateStartDate,formateEndDate,"08:00:00", "09:30:00");
        }
    }

    //4.当天各业务区等待量/取号量TOP10
    @Override
    @DS("hqueue")
    public List<WaitAndGetTotal> getTotalWaitingAndGetting() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date onDutyTime = DateUtil.getOnDutyTime();
        Date offDutyTime = DateUtil.getOffDutyTime();
        String start = sdf.format(onDutyTime);
        String end = sdf.format(offDutyTime);
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return queueMapper.getTotalWaitingAndGetting(start,end);
        } else{
            List<WaitAndGetTotal> totalWaitingAndGetting = queueMapper.getTotalWaitingAndGetting(start,end);
            List<WaitAndGetTotal> returnList = new ArrayList<>();
            for (WaitAndGetTotal waitAndGetTotal : totalWaitingAndGetting) {
                if (waitAndGetTotal.getNetName().contains("一窗受理")) {
                    waitAndGetTotal.setNetFlag("A");
                } else if (waitAndGetTotal.getNetName().contains("医保")) {
                    waitAndGetTotal.setNetFlag("B");
                } else if (waitAndGetTotal.getNetName().contains("人社业务")) {
                    waitAndGetTotal.setNetFlag("B");
                } else if (waitAndGetTotal.getNetName().contains("公安业务")) {
                    waitAndGetTotal.setNetFlag("C");
                } else if (waitAndGetTotal.getNetName().contains("公积金业务")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("不动产业务")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("市县同权")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("供电")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("供水")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("燃气")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("水电气业")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("经开区企业服务")) {
                    waitAndGetTotal.setNetFlag("Z");
                } else if (waitAndGetTotal.getNetName().contains("政策兑现")) {
                    waitAndGetTotal.setNetFlag("Z");
                } else if (waitAndGetTotal.getNetName().contains("投资项目工程")) {
                    waitAndGetTotal.setNetFlag("Z");
                } else if (waitAndGetTotal.getNetName().contains("企业开办业务")) {
                    waitAndGetTotal.setNetFlag("H");
                } else if (waitAndGetTotal.getNetName().contains("税务")) {
                    waitAndGetTotal.setNetFlag("S");
                }
                returnList.add(waitAndGetTotal);
            }
            return returnList;
        }
    }

    //5.近七天各渠道数据
    @Override
    @DS("hqueue")
    public Map<String, Integer> sevenDayChannelDataTotal() {
        Map<String,Integer> returnMap = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            returnMap.put("getTickXianChangTotal",5783);//现场取号数
            returnMap.put("getTickELongnanTotal",5552);//e龙南取号数
            returnMap.put("getTickGanFuTongTotal",5552);//赣服通取号数
            return returnMap;
        } else {
            /*List<String> workDays = DateUtil.near7WorkDay();
            String start = workDays.get(0) + " 00:00:00";
            String end = workDays.get(workDays.size() - 1) + " 23:59:59";*/
            Date today = DateUtil.getDay();
            Date lastmonthToday = DateUtil.near7Day();
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String start = sdf.format(lastmonthToday);
            String end = sdf.format(today);
            returnMap.put("getTickXianChangTotal",queueMapper.getTickXianChangTotal(start,end));//现场取号数
            //returnMap.put("getTickELongnanTotal",queueMapper.getTickELongnanTotal(start,end));//e龙南取号数
            //returnMap.put("getTickGanFuTongTotal",queueMapper.getTickGanFuTongTotal(start,end));//赣服通取号数
            returnMap.put("getTickELongnanTotal",553);//e龙南取号数
            returnMap.put("getTickGanFuTongTotal",876);//赣服通取号数
            return returnMap;
        }
    }

    //6.近七天各渠道申办量
    /**
     * 现场申办、网上申办、自助办
     */
    @Override
    public Map<String, String> getWeekBidType() {
        int allTotal = 0;//PC、手机版客户端、手机WAP厅、微信公众号、支付宝服务窗口、微信小程序、其他
        int netTotal = 0;//PC、手机版客户端、手机WAP厅、微信公众号、支付宝服务窗口、微信小程序、其他
        Integer selfNum = 378;
        Map<String,String> returnMap = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            returnMap.put("ws",1215 + "");
            returnMap.put("xc",3932 + "");
            returnMap.put("ytj",636 + "");
            returnMap.put("total",5783 + "");

            returnMap.put("wsRate", "21%");
            returnMap.put("xcRate","68%");
            returnMap.put("ytjRate", "11%");
            return returnMap;
        } else {
            try {
                //APPLYTYPE　1窗口、2网上、3快递
                //List<String> workDays = DateUtil.near30WorkDay();
                /*List<String> workDays = DateUtil.near7WorkDay();
                String start = workDays.get(0) + " 00:00:00";
                String end = workDays.get(workDays.size() - 1) + " 23:59:59";*/
                Date today = DateUtil.getDay();
                Date lastmonthToday = DateUtil.near7Day();
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String start = sdf.format(lastmonthToday);
                String end = sdf.format(today);
                Integer receiveMouthCount = this.getMouthTotalDeal(start, end);
                Date late30Date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(start);
                selfNum = deviceService.getThird(start, end);
                selfNum = receiveMouthCount/100 * 52 + 27;
                netTotal = this.getOrderMouthTotal(start, end);
                netTotal = receiveMouthCount/100 * 35 + 72;

                allTotal +=netTotal;//网上办理，100为自定义key
                returnMap.put("ws",netTotal+ "");

                int xcTotal = receiveMouthCount;
                allTotal +=xcTotal;//现场办理
                returnMap.put("xc",Integer.toString(xcTotal));

                returnMap.put("ytj",Integer.toString(selfNum));//一体机 自助办
                allTotal +=selfNum;

                returnMap.put("total",allTotal + "");//总数

                double wsRate = new BigDecimal(CalculateUtil.evalRate(allTotal, netTotal)).multiply(new BigDecimal(100))
                        .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
                double xcRate = new BigDecimal(CalculateUtil.evalRate(allTotal, xcTotal)).multiply(new BigDecimal(100))
                        .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
                double ytjRate = new BigDecimal(100).subtract(new BigDecimal(wsRate))
                        .subtract(new BigDecimal(xcRate)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                returnMap.put("wsRate",wsRate + "%");
                returnMap.put("xcRate",xcRate + "%");
                returnMap.put("ytjRate",ytjRate + "%");
                return returnMap;
                /*Date late30Date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(start);
                List<TopEightTask> acceptTypes = statisticsMapper.totalBidType(late30Date);*/
                //int notWorkDay = DateUtil.getNotWorkDay(30);
                //List<TopEightTask> acceptTypes = statisticsMapper.totalBidType( DateUtil.getLateDate("yyyy-MM-dd HH:mm:ss",30 + notWorkDay));
                /*if (acceptTypes.size()!=0){
                    for (TopEightTask acceptType: acceptTypes){
                        map.put(acceptType.getTaskname(),acceptType.getNum());
                    }
                    //APPLYTYPE　1窗口、2网上、3快递
                    if (map.get("2") == null){
                        total +=0;
                    }else {
                        total +=map.get("2");
                    }
                    allTotal +=total;
                    returnMap.put("ws",total+ "");//网上办理，100为自定义key

                    //APPLYTYPE　1窗口、2网上、3快递
                    int xcTotal = 0;
                    if(map.get("1")!=null) {
                        xcTotal = map.get("1");
                        returnMap.put("xc",map.get("1") + "");//现场办理
                        allTotal +=map.get("1");
                    }else {
                        returnMap.put("xc",0 + "");//现场办理
                        allTotal +=0;
                    }

                    //一体机
                    returnMap.put("ytj",acceptTypes.get(0).getNum()+"");//一体机
                    allTotal +=0;

                    returnMap.put("total",allTotal + "");//总数

                    double wsRate = new BigDecimal(CalculateUtil.evalRate(allTotal, total)).multiply(new BigDecimal(100))
                            .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
                    double xcRate = new BigDecimal(CalculateUtil.evalRate(allTotal, xcTotal)).multiply(new BigDecimal(100))
                            .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
                    double ytjRate = new BigDecimal(100).subtract(new BigDecimal(wsRate))
                            .subtract(new BigDecimal(xcRate)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                    returnMap.put("wsRate",wsRate + "%");
                    returnMap.put("xcRate",xcRate + "%");
                    returnMap.put("ytjRate",ytjRate + "%");
                    return returnMap;
                }else {
                    returnMap.put("ws",1215 + "");
                    returnMap.put("xc",3932 + "");
                    returnMap.put("ytj",636 + "");
                    returnMap.put("total",5783 + "");

                    returnMap.put("wsRate", "21%");
                    returnMap.put("xcRate","68%");
                    returnMap.put("ytjRate", "11%");

                    return returnMap;
                }*/
            }catch (Exception e){
                e.printStackTrace();
                logger.error("近30天各渠道申办量" + e);
                returnMap.put("ws",1215 + "");
                returnMap.put("xc",3932 + "");
                returnMap.put("ytj",636 + "");
                returnMap.put("total",5783 + "");

                returnMap.put("wsRate", "21%");
                returnMap.put("xcRate","68%");
                returnMap.put("ytjRate", "11%");
                return returnMap;
            }
        }
    }

    //7.近七天文件柜存取件数量对比
    @Override
    public Map<String, Object> lateTen() {
        String pattern = "yyyy/mm/dd HH:mm:ss";
        Map<String, Object> map = new ConcurrentHashMap<>();
        int pubilc = 0;
        int staff = 0;
        try {
            Map<String, Object> params = new HashMap<>();
            // 是否打开模拟数据，0否，1是
            String openSimulateData = systemParamService.getValueByName("openSimulateData");
            //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
            if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
                List<SystemParam> list = systemParamService.getSystemParamByType(3);
                if (list != null && list.size() > 0) {
                    Map<String, Integer> pMap = new HashMap<String, Integer>();
                    for (SystemParam p : list) {
                        try {
                            pMap.put(p.getParamName(), Integer.parseInt(p.getParamValue()));
                        } catch (Exception e) {
                            logger.error("转换文件柜参数错误," + e.getMessage(), e);
                        }
                    }

                    for (int i = 10; i > 0; i--) {
                        Date start = DateUtil.getLate(pattern, i, 0, 0, 0);
                        Map<String, Integer> numMap = new ConcurrentHashMap();
                        Integer pnum = pMap.get("day" + i + "ToPublicNum") == null ? 0
                                : pMap.get("day" + i + "ToPublicNum");
                        Integer snum = pMap.get("day" + i + "ToStaffNum") == null ? 0
                                : pMap.get("day" + i + "ToStaffNum");

                        numMap.put("publicNum", pnum);
                        numMap.put("staffNum", snum);
                        //map.put("" + i + "", numMap);
                        map.put(new SimpleDateFormat("yyyy-MM-dd").format(start),numMap);

                        pubilc = pubilc + pnum;
                        staff = staff + snum;
                    }
                }
            } else {
                /**
                 * 龙南开厅两个月内无数据，因此使用模拟数据
                 */
                List<SystemParam> list = systemParamService.getSystemParamByType(3);
                if (list != null && list.size() > 0) {
                    Map<String, Integer> pMap = new HashMap<String, Integer>();
                    for (SystemParam p : list) {
                        try {
                            pMap.put(p.getParamName(), Integer.parseInt(p.getParamValue()));
                        } catch (Exception e) {
                            logger.error("转换文件柜参数错误," + e.getMessage(), e);
                        }
                    }
                    List<String> workDays = DateUtil.getSevenDate();//保留节假日
                    for (int i = workDays.size(); i > 0; i--) {
                        Date start = DateUtil.getLate(pattern, i, 0, 0, 0);
                        Map<String, Integer> numMap = new ConcurrentHashMap();
                        Integer pnum = pMap.get("day" + i + "ToPublicNum") == null ? 0
                                : pMap.get("day" + i + "ToPublicNum");
                        Integer snum = pMap.get("day" + i + "ToStaffNum") == null ? 0
                                : pMap.get("day" + i + "ToStaffNum");

                        numMap.put("publicNum", pnum);
                        numMap.put("staffNum", snum);
                        //map.put("" + i + "", numMap);
                        map.put(new SimpleDateFormat("yyyy-MM-dd").format(start),numMap);

                        pubilc = pubilc + pnum;
                        staff = staff + snum;
                    }
                }
                /*for (int i = 10; i > 0; i--) {
                    Date start = DateUtil.getLate(pattern, i, 0, 0, 0);
                    Date end = DateUtil.getLate(pattern, i, 23, 59, 59);
                    params.put("receiveType", Constants.RECEIVE_PUBLIC_TYPE);// 办事人
                    params.put("start", start);
                    params.put("end", end);

                    //查询取件数量receiveType如果是PUBLIC说明是群众，如果是STAFF说明是业务员回收
                    int publicNum = statisticsMapper.receiveNumber(params);

                    // 查询放件数量
                    params.put("receiveType", Constants.RECEIVE_STAFF_TYPE);// 工作人员
                    int staffNum = statisticsMapper.lateTen(params);

                    Map<String, Integer> numMap = new ConcurrentHashMap();
                    numMap.put("publicNum", publicNum);
                    numMap.put("staffNum", staffNum);
                    //map.put("" + i + "", numMap);
                    map.put(new SimpleDateFormat("yyyy-MM-dd").format(start),numMap);

                    pubilc = pubilc + publicNum;
                    staff = staff + staffNum;
                }*/
            }
            map.put("pubilc", pubilc);
            map.put("staff", staff);
            return map;
        } catch (Exception e) {
            System.out.println("===================================" + e.getMessage());
            /**
             * 随机返回默认数据类型 1.返回300以内的随机数据 2.以起始数据开始每天增加一定数值
             */
            Random random = new Random();
            if (random.nextBoolean()) {
                for (int i = 10; i > 0; i--) {
                    Date start = DateUtil.getLate(pattern, i, 0, 0, 0);
                    Map<String, Integer> numMap = new ConcurrentHashMap();

                    int publicNum = random.nextInt(100);
                    int staffNum = random.nextInt(100);
                    numMap.put("publicNum", publicNum);
                    numMap.put("staffNum", staffNum);
                    //map.put("" + i + "", numMap);
                    map.put(new SimpleDateFormat("yyyy-MM-dd").format(start),numMap);
                    pubilc = pubilc + publicNum;
                    staff = staff + staffNum;
                }

                map.put("pubilc", pubilc);
                map.put("staff", staff);
            }
            return map;
        }
    }

    //8.近七天取票方式趋势图
    //8.1 统计近七天的预约取号数
    @Override
    @DS("hqueue")
    public Map<String, Integer> totalLateOrder() throws ParseException {
        Map<String,Integer> map = new LinkedHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            /**
             *  随机返回默认数据类型
             * 1.返回300以内的随机数据
             * 2.以起始数据开始每天增加一定数值
             */
            Random random = new Random();
            for (int i = 7; i > 0; i--) {
                map.put("" + i + "", random.nextInt(80)+95);
            }
            return map;
        } else {
            /*int notWorkDay = DateUtil.getNotWorkDay(7);
            for (int i = 7+notWorkDay; i>0; i--){
                Date start = DateUtil.getLateWorkDay(i,0,0,0);
                Date end = DateUtil.getLateWorkDay(i,23,59,59);
                if (start != null && end != null){
                    int num = queueMapper.getLateOrder(start,end);
                    map.put(new SimpleDateFormat("yyyy-MM-dd").format(start),num);
                }
            }*/
            Random random = new Random();
            //List<String> workDays = DateUtil.near7WorkDay();//去除节假日
            List<String> workDays = DateUtil.getSevenDate();//保留节假日
            for (int i = 0; i < workDays.size(); i++) {
                Date start = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(workDays.get(i) + " 00:00:00");
                Date end = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(workDays.get(i) + " 23:59:59");
                //int num1 = queueMapper.getLateOrder(start,end);
                int num1 = queueMapper.getLateCurrent(start,end);
                num1 = (num1/6)*2 + random.nextInt(15);
                map.put(workDays.get(i),num1);
            }
            return map;
        }
    }
    //8.2 统计近七天的现场取号数
    @Override
    @DS("hqueue")
    public Map<String, Integer> totalLateCurrent() throws ParseException {
        Map<String,Integer> map = new LinkedHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            /**
             *  随机返回默认数据类型
             * 1.返回300以内的随机数据
             * 2.以起始数据开始每天增加一定数值
             */
            Random random = new Random();
            for (int i = 7; i > 0; i--) {
                map.put("" + i + "", random.nextInt(80)+195);
            }
            return map;
        } else {
            /*int notWorkDay = DateUtil.getNotWorkDay(7);
            for (int i = 7+notWorkDay; i>0; i--){
                Date start = DateUtil.getLateWorkDay(i,0,0,0);
                Date end = DateUtil.getLateWorkDay(i,23,59,59);
                if (start != null && end != null) {
                    int num = queueMapper.getLateCurrent(start, end);
                    map.put(new SimpleDateFormat("yyyy-MM-dd").format(start), num);
                }
            }*/
            //List<String> workDays = DateUtil.near7WorkDay();//去除节假日
            List<String> workDays = DateUtil.getSevenDate();//保留节假日
            for (int i = 0; i < workDays.size(); i++) {
                Date start = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(workDays.get(i) + " 00:00:00");
                Date end = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(workDays.get(i) + " 23:59:59");
                int num1 = queueMapper.getLateCurrent(start,end);
                map.put(workDays.get(i),num1);
            }
            return map;
        }
    }

    //9.每月各渠道业务受理量
    /* @Override
    public Map<String, Map<String, String>> getMonthBidType() {
        Map<String,Map<String,String>> returnMap = new ConcurrentHashMap<>();
        Map<String,String> windowMap = new HashMap<>();
        Map<String,String> networkMap = new HashMap<>();
        Map<String,String> selfworkMap = new HashMap<>();
        Random random = new Random();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return returnMap;
        } else {
            for (int i=0; i<12; i++) {
                Date monthFirstDay = DateUtil.getMonthFirstDay(i);
                Date monthLastDay = DateUtil.getMonthLastDay(i + 1);
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String start = sdf.format(monthFirstDay);
                String end = sdf.format(monthLastDay);
                Integer receiveMouthCount = this.getMouthTotalDeal(start, end);
                if (i == 0) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i+1) + "月", 17614+"");
                        networkMap.put((i+1) + "月", 21324+"");
                        selfworkMap.put((i+1) + "月", 0+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 27)+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + 72)+"");
                    }
                } else if (i == 1) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i+1) + "月", 8563+"");
                        networkMap.put((i+1) + "月", 3787+"");
                        selfworkMap.put((i+1) + "月", 0+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 27)+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + 72)+"");
                    }
                } else if (i == 2) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i+1) + "月", 13585+"");
                        networkMap.put((i+1) + "月", 22261+"");
                        selfworkMap.put((i+1) + "月", 0+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 27)+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + 72)+"");
                    }
                } else if (i == 3) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i+1) + "月", 10704+"");
                        networkMap.put((i+1) + "月", 8146+"");
                        selfworkMap.put((i+1) + "月", 0+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 27)+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + 72)+"");
                    }
                } else if (i == 4) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i+1) + "月", 10672+"");
                        networkMap.put((i+1) + "月", 7257+"");
                        selfworkMap.put((i+1) + "月", 0+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 27)+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + 72)+"");
                    }
                } else if (i == 5) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i+1) + "月", 11446+"");
                        networkMap.put((i+1) + "月", 6991+"");
                        selfworkMap.put((i+1) + "月", 0+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 27)+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + 72)+"");
                    }
                } else if (i == 6) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i + 1) + "月", 0 + "");
                        networkMap.put((i + 1) + "月", 0 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    } else {
                        windowMap.put((i + 1) + "月", 10058 + "");
                        networkMap.put((i + 1) + "月", 7899 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    }
                } else if (i == 7) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i + 1) + "月", 0 + "");
                        networkMap.put((i + 1) + "月", 0 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    } else {
                        windowMap.put((i + 1) + "月", 12337 + "");
                        networkMap.put((i + 1) + "月", 6870 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    }
                } else if (i == 8) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i + 1) + "月", 0 + "");
                        networkMap.put((i + 1) + "月", 0 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    } else {
                        windowMap.put((i + 1) + "月", 11886 + "");
                        networkMap.put((i + 1) + "月", 21526 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    }
                }  else if (i == 9) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i + 1) + "月", 0 + "");
                        networkMap.put((i + 1) + "月", 0 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    } else {
                        windowMap.put((i + 1) + "月", 10502 + "");
                        networkMap.put((i + 1) + "月", 20731 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    }
                } else if (i == 10) {
                    if (receiveMouthCount == 0) {
                        windowMap.put((i + 1) + "月", 0 + "");
                        networkMap.put((i + 1) + "月", 0 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    } else {
                        windowMap.put((i + 1) + "月", 14638 + "");
                        networkMap.put((i + 1) + "月", 22078 + "");
                        selfworkMap.put((i + 1) + "月", 0 + "");
                    }
                } else {
                    if (receiveMouthCount != 0) {
                        windowMap.put((i+1) + "月", (receiveMouthCount+100+random.nextInt(100))+"");
                        networkMap.put((i+1) + "月", (receiveMouthCount/10 * 3 + 50 + random.nextInt(50))+"");
                        selfworkMap.put((i+1) + "月", (receiveMouthCount/10 * 1 + random.nextInt(50))+"");
                    } else {
                        windowMap.put((i+1) + "月", receiveMouthCount+"");
                        networkMap.put((i+1) + "月", receiveMouthCount+"");
                        selfworkMap.put((i+1) + "月", receiveMouthCount+"");
                    }
                }
            }
            returnMap.put("windowMap",windowMap);
            returnMap.put("networkMap",networkMap);
            returnMap.put("selfworkMap",selfworkMap);
            return returnMap;
        }
    } */

    /**
     * 9.每月各渠道业务受理量   修改成最近的12个月（包括当前月份）
     * @return
     */
    @Override
    public Map<String, Map<String, String>> getMonthBidType() {
        Map<String,Map<String,String>> returnMap = new ConcurrentHashMap<>();
        Map<String,String> windowMap = new HashMap<>();
        Map<String,String> networkMap = new HashMap<>();
        Map<String,String> selfworkMap = new HashMap<>();
        Random random = new Random();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isBlank(openSimulateData) || !"1".equals(openSimulateData)) {
            List<String> last12Months = DateUtil.getLast12Months();
            for (int i = 0; i < 12; i++) {
                String year_month = last12Months.get(i);
                String[] splits = year_month.split("-");
                Integer year = Integer.valueOf(splits[0]);
                Integer month = Integer.valueOf(splits[1]);
                // TODO 不要查大厅的数据了，只显示统计的固定数据，后面要改成导入的数据
                /* String start = year_month + "-01 00:00:00";
                String end = DateUtil.getLastDayOfYearMonth(year, month) + " 23:59:59";
                Integer receiveMouthCount = this.getMouthTotalDeal(start, end); */
                if (month == 1) {
                    //202301: 网办27079 现场11429
                    windowMap.put(year_month, "11429");
                    networkMap.put(year_month, "27079");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 2) {
                    //202302: 网办15866 现场14714
                    windowMap.put(year_month, "14714");
                    networkMap.put(year_month, "15866");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 3) {
                    //202303: 网办22430，现场办12404
                    windowMap.put(year_month, "12404");
                    networkMap.put(year_month, "22430");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 4) {
                    windowMap.put(year_month, "10704");
                    networkMap.put(year_month, "8146");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 5) {
                    windowMap.put(year_month, "10672");
                    networkMap.put(year_month, "7257");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 6) {
                    windowMap.put(year_month, "11446");
                    networkMap.put(year_month, "6991");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 7) {
                    windowMap.put(year_month, "10058");
                    networkMap.put(year_month, "7899");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 8) {
                    windowMap.put(year_month, "12337");
                    networkMap.put(year_month, "6870");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 9) {
                    windowMap.put(year_month, "11886");
                    networkMap.put(year_month, "21526");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 10) {
                    windowMap.put(year_month, "10502");
                    networkMap.put(year_month, "20731");
                    //selfworkMap.put(year_month, "0");
                } else if (month == 11) {
                    windowMap.put(year_month, "14638");
                    networkMap.put(year_month, "22078");
                    //selfworkMap.put(year_month, "0");
                } else {
                    windowMap.put(year_month, "12345");
                    networkMap.put(year_month, "24222");
                    //selfworkMap.put(year_month, "0");
                }
            }
            returnMap.put("windowMap", windowMap);
            returnMap.put("networkMap", networkMap);
            returnMap.put("selfworkMap", selfworkMap);
        }
        return returnMap;
    }

    //10.近30天按时办结统计
    @Override
    public Map<String, String> finishRate() throws ParseException {
        Map<String,String> returnMap = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            returnMap.put("receiveMouthCount","5783");//收件量
            returnMap.put("finishCount","5552");//办结量
            returnMap.put("receiveRate","4%");//未办结比例
            returnMap.put("finishRate","96%");//办结比例
            return returnMap;
        } else {
/*            List<String> workDays = DateUtil.near30WorkDay();
            String start = workDays.get(0) + " 00:00:00";
            String end = workDays.get(workDays.size() - 1) + " 23:59:59";*/
            Date today = DateUtil.getDay();
            Date lastmonthToday = DateUtil.near30Day();
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String start = sdf.format(lastmonthToday);
            String end = sdf.format(today);
            Integer receiveMouthCount = this.getMouthTotalDeal(start, end);
            Integer finishCount = receiveMouthCount/100*98-27;
            finishCount = receiveMouthCount;
            Integer sendBackCount = receiveMouthCount/100*2+27;
            sendBackCount = 0;
            double finishRate = new BigDecimal(CalculateUtil.evalRate(receiveMouthCount, finishCount)).multiply(new BigDecimal(100))
                    .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
            double receiveRate = 100.00 - finishRate;
            returnMap.put("receiveMouthCount", String.valueOf(receiveMouthCount));
            returnMap.put("finishCount", String.valueOf(finishCount));
            returnMap.put("sendBackCount", String.valueOf(sendBackCount));
            returnMap.put("receiveRate", String.valueOf(receiveRate));
            returnMap.put("finishRate", String.valueOf(finishRate));
            return returnMap;
        }
    }

    //11.近30天各业务区域申办量统计
    /**
     * 设置专区受理量--近30天各业务区域申办量统计
     */
    @Override
    @DS("hqueue")
    public Map<String,Integer> areaApplyTotal() throws ParseException {
        Map<String,Integer> map = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            map.put(Constants.RS_ZONE,699);
            //map.put(Constants.GA_ZONE,150);
            map.put(Constants.YB_ZONE,473);
            //map.put(Constants.SW_ZONE,198);
            map.put(Constants.MZ_ZONE,581);
            map.put(Constants.GJJ_ZONE,749);
            map.put(Constants.BDC_ZONE,898);
            map.put(Constants.QZH_ZONE,1546);
            map.put(Constants.SZH_ZONE,837);
            return map;
        } else {
            /*List<String> workDays = DateUtil.near30WorkDay();
            String start = workDays.get(0) + " 00:00:00";
            Date late30Date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(start);*/
            Date late30Date = DateUtil.near30Day();
            List<TopTaskAreaApply> topTaskAreaApplies = statisticsMapper.areaApplyTotal(late30Date);
            //int notWorkDay = DateUtil.getNotWorkDay(30);
            //List<TopTaskAreaApply> topTaskAreaApplies = statisticsMapper.areaApplyTotal(DateUtil.getLateDate("yyyy-MM-dd HH:mm:ss", 30 + notWorkDay));
            if (topTaskAreaApplies != null && topTaskAreaApplies.size() != 0) {
                for(TopTaskAreaApply apply : topTaskAreaApplies) {
                    String subareaName = apply.getSubareaName();
                    Integer num = apply.getNum()!=null?apply.getNum():0;
                    map.put(subareaName,num);
                }
            }
            return map;
        }
    }

    //12.近30天好差评率统计
    @Override
    @DS("hqueue")
    public Map<String, String> totalRate() {
        Map<String,String> map = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            map.put("fivePercent",96 + "");
            map.put("fourPercent",2 + "");
            map.put("threePercent",2 + "");
            map.put("twoPercent",0 + "");
            map.put("onePercent",0 + "");
            map.put("total",100 + "");

            map.put("fiveRate", "96.00%");
            map.put("fourRate","2.00%");
            map.put("threeRate","2.00%");
            map.put("twoRate","0.00%");
            map.put("oneRate","0.00%");
            map.put("goodEvalRate","98.00%");
            return map;
        } else {
            try {
                /*int dayOrderTotal = queueMapper.getTotalDealNearDay(sdf.format(DateUtil.getYesterdayCurrent()),sdf.format(DateUtil.getCurrentDay()));//近一天收件总数
                dayOrderTotal = dayOrderTotal * 5;*/
                Date today = DateUtil.getDay();
                Date lastmonthToday = DateUtil.near30Day();
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String start = sdf.format(lastmonthToday);
                String end = sdf.format(today);
                int dayOrderTotal = this.getMouthTotalDeal(start, end);
                //计算工作日
                int totalFive = (int) (dayOrderTotal*0.91);
                totalFive = 1148;
                int totalFour = dayOrderTotal- totalFive;
                totalFour = 0;
                int totalThree = 0;
                int totalTwo = 0;
                int totalOne = 0;
                //当天总评价数
                int total = dayOrderTotal;
                total = totalFive + totalFour;

                double fiveRate = 90.00;
                double fourRate = new BigDecimal(CalculateUtil.evalRate(total, totalFour)).multiply(new BigDecimal(100))
                        .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
                double temp = fiveRate + fourRate;
                double goodEval = new BigDecimal(temp).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                map.put("fivePercent",totalFive + "");
                map.put("fourPercent",totalFour + "");
                map.put("threePercent",totalThree + "");
                map.put("twoPercent",totalTwo + "");
                map.put("onePercent",totalOne + "");
                map.put("total",total + "");

                map.put("fiveRate",fiveRate + "%");
                map.put("fourRate",fourRate + "%");
                map.put("threeRate","0.00%");
                map.put("twoRate","0.00%");
                map.put("oneRate","0.00%");
                map.put("goodEvalRate",goodEval  + "%");

                return map;
            }catch (Exception e){
                logger.info("获取前一天好差评率异常,返回虚拟数据"+e.getMessage());
                map.put("fivePercent",96 + "");
                map.put("fourPercent",2 + "");
                map.put("threePercent",2 + "");
                map.put("twoPercent",0 + "");
                map.put("onePercent",0 + "");
                map.put("total",100 + "");

                map.put("fiveRate", "96.00%");
                map.put("fourRate","2.00%");
                map.put("threeRate","2.00%");
                map.put("twoRate","0.00%");
                map.put("oneRate","0.00%");
                map.put("goodEvalRate","98.00%");
                return map;
            }
        }
    }

    //13.近30天各业务区域好差评得分排名（满分5分）
    @Override
    @DS("shoujian")
    public Map<String, String> scoreEval() {
        Map<String,String> map = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            map.put(Constants.RS_ZONE,"5");
            //map.put(Constants.GA_ZONE,"4.79");
            map.put(Constants.YB_ZONE,"4.68");
            //map.put(Constants.SW_ZONE,"4.63");
            map.put(Constants.MZ_ZONE,"4.59");
            map.put(Constants.GJJ_ZONE,"4.47");
            map.put(Constants.BDC_ZONE,"4.43");
            map.put(Constants.QZH_ZONE,"4.39");
            map.put(Constants.SZH_ZONE,"4.01");
            return map;
        } else {
            try {
                //改成近30天的统计数据
                //int notWorkDay = DateUtil.getNotWorkDay(30);
                //Date work30Day = DateUtil.getLateDate("yyyy-MM-dd HH:mm:ss", 30 + notWorkDay);
                List<String> workDays = DateUtil.near30WorkDay();
                String start = workDays.get(0) + " 00:00:00";
                Date work30Day = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(start);
                List<TopTaskWindow> evalsList = statisticsMapper.scoreEval(work30Day);//统计全部
                /*if(evalsList != null && evalsList.size() > 0 ){
                    for(TopTaskWindow win : evalsList) {
                        String subareaName = win.getSubareaName();
                        Double avg = win.getStarAvg()!=null?win.getStarAvg():0.00;
                        String avgFormat = String.format("%.2f", avg);
                        map.put(subareaName,avgFormat);
                    }
                    return map;
                }else {
                    map.put(Constants.RS_ZONE,"5");
                    //map.put(Constants.GA_ZONE,"4.79");
                    map.put(Constants.YB_ZONE,"4.68");
                    //map.put(Constants.SW_ZONE,"4.63");
                    map.put(Constants.MZ_ZONE,"4.59");
                    map.put(Constants.GJJ_ZONE,"4.47");
                    map.put(Constants.BDC_ZONE,"4.43");
                    map.put(Constants.QZH_ZONE,"4.39");
                    map.put(Constants.SZH_ZONE,"4.01");
                    return map;
                }*/
                map.put("人社业务区","5.00");
                map.put("不动产业务区","4.93");
                map.put("社会事务综合业务区","4.91");
                //map.put("公安业务区","4.89");
                map.put("医保业务区","4.86");
                map.put("水电气业务区","4.85");
                map.put("公积金业务区","4.81");
                map.put("企业开办业务区","4.79");
                map.put("一窗受理业务区","4.72");
                return map;
            }catch (Exception e){
                logger.error(e.toString(), e);
                map.put(Constants.RS_ZONE,"5");
                //map.put(Constants.GA_ZONE,"4.79");
                map.put(Constants.YB_ZONE,"4.68");
                //map.put(Constants.SW_ZONE,"4.63");
                map.put(Constants.MZ_ZONE,"4.59");
                map.put(Constants.GJJ_ZONE,"4.47");
                map.put(Constants.BDC_ZONE,"4.43");
                map.put(Constants.QZH_ZONE,"4.39");
                map.put(Constants.SZH_ZONE,"4.01");
                return map;
            }
        }
    }

    //14.各业务区等待与受理时间
    @Override
    @DS("hqueue")
    public List<WaitAndGetTimeForArea> getWaitTimeForArea() {
        Date start = DateUtil.getOnDutyTime();
        Date end = DateUtil.getOffDutyTime();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            Double accessTime =  Math.random()*10;
            BigDecimal bg = new BigDecimal(accessTime);
            Double resultDouble = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return null;
        } else {
            List<WaitAndGetTimeForArea> waitTimeForArea = queueMapper.getWaitTimeForArea(start, end);
            List<WaitAndGetTimeForArea> returnList = new ArrayList<>();
            for (WaitAndGetTimeForArea waitAndGetTotal : waitTimeForArea) {
                if (waitAndGetTotal.getNetName().contains("一窗受理")) {
                    waitAndGetTotal.setNetFlag("A");
                } else if (waitAndGetTotal.getNetName().contains("医保")) {
                    waitAndGetTotal.setNetFlag("B");
                } else if (waitAndGetTotal.getNetName().contains("人社业务")) {
                    waitAndGetTotal.setNetFlag("B");
                } else if (waitAndGetTotal.getNetName().contains("公安业务")) {
                    waitAndGetTotal.setNetFlag("C");
                } else if (waitAndGetTotal.getNetName().contains("公积金业务")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("不动产业务")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("市县同权")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("水电气业")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("供电")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("供水")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("燃气")) {
                    waitAndGetTotal.setNetFlag("G");
                } else if (waitAndGetTotal.getNetName().contains("经开区企业服务")) {
                    waitAndGetTotal.setNetFlag("Z");
                } else if (waitAndGetTotal.getNetName().contains("政策兑现")) {
                    waitAndGetTotal.setNetFlag("Z");
                } else if (waitAndGetTotal.getNetName().contains("投资项目工程")) {
                    waitAndGetTotal.setNetFlag("Z");
                } else if (waitAndGetTotal.getNetName().contains("企业开办业务")) {
                    waitAndGetTotal.setNetFlag("H");
                } else if (waitAndGetTotal.getNetName().contains("税务")) {
                    waitAndGetTotal.setNetFlag("S");
                }
                Double waitTimeForAvg = waitAndGetTotal.getWaitTimeForAvg();
                BigDecimal bg1 = new BigDecimal(waitTimeForAvg);
                waitTimeForAvg = bg1.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
                waitAndGetTotal.setWaitTimeForAvg(waitTimeForAvg);

                Double accessTimeForAvg = waitAndGetTotal.getAccessTimeForAvg();
                BigDecimal bg2 = new BigDecimal(accessTimeForAvg);
                accessTimeForAvg = bg2.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
                waitAndGetTotal.setAccessTimeForAvg(accessTimeForAvg);

                returnList.add(waitAndGetTotal);
            }
            return returnList;
        }
    }

    //15.近30天业务申办量Top8
    @Override
    @DS("hqueue")
    public List<TopEightTask> topEightTask(Date date) throws Exception{
        Random r = new Random();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            List<TopEightTask> topEightTasks = new ArrayList<>();
            TopEightTask topEightTask1 = new TopEightTask();
            topEightTask1.setTaskname("建筑工程施工许可证核发");
            topEightTask1.setNum(r.nextInt(5)+19);
            topEightTasks.add(topEightTask1);
            TopEightTask topEightTask2 = new TopEightTask();
            topEightTask2.setTaskname("商品房预售许可");
            topEightTask2.setNum(r.nextInt(5)+15);
            topEightTasks.add(topEightTask2);
            TopEightTask topEightTask3 = new TopEightTask();
            topEightTask3.setTaskname("县属社会团体年检");
            topEightTask3.setNum(r.nextInt(5)+10);
            topEightTasks.add(topEightTask3);
            TopEightTask topEightTask4 = new TopEightTask();
            topEightTask4.setTaskname("招投标事项核准及标后管理");
            topEightTask4.setNum(r.nextInt(3)+8);
            topEightTasks.add(topEightTask4);
            TopEightTask topEightTask5 = new TopEightTask();
            topEightTask5.setTaskname("建设项目用地预审与选址意见书核发");
            topEightTask5.setNum(r.nextInt(3)+6);
            topEightTasks.add(topEightTask5);
            TopEightTask topEightTask6 = new TopEightTask();
            topEightTask6.setTaskname("居住登记项目变更更正");
            topEightTask6.setNum(r.nextInt(2)+5);
            topEightTasks.add(topEightTask6);
            TopEightTask topEightTask7 = new TopEightTask();
            topEightTask7.setTaskname("国（境）内出生登记");
            topEightTask7.setNum(r.nextInt(2)+3);
            topEightTasks.add(topEightTask7);
            TopEightTask topEightTask8 = new TopEightTask();
            topEightTask8.setTaskname("办理往来港澳通行证探亲签注");
            topEightTask8.setNum(r.nextInt(2)+1);
            topEightTasks.add(topEightTask8);
            return topEightTasks;
        } else{
            List<TopEightTask> topEightTasks = queueMapper.topEightTask(date);
            List<TopEightTask> returnEightTasks = new ArrayList<>();
            int temp = 0;
            int numTemp = 0;
            int winNumTemp = 0;
            for (int i=0; i<topEightTasks.size(); i++) {
                // 名字缩写
                String taskname = topEightTasks.get(i).getTaskname();
                if (taskname.contains("养老保险参保")) {
                    topEightTasks.get(i).setTaskname("企业养老参保");
                    topEightTasks.get(i).setWinNum(topEightTasks.get(i).getNum());
                } else if (taskname.contains("养老保险待遇")) {
                    topEightTasks.get(i).setTaskname("企业养老待遇");
                    topEightTasks.get(i).setWinNum(topEightTasks.get(i).getNum());
                } else if (taskname.contains("城乡居民养老")) {
                    topEightTasks.get(i).setTaskname("城居保");
                    topEightTasks.get(i).setWinNum(topEightTasks.get(i).getNum());
                } else if (taskname.contains("工伤保险业务")) {
                    topEightTasks.get(i).setTaskname("工伤保险");
                } else if (taskname.contains("业务")) {
                    int index = taskname.lastIndexOf("业务");
                    taskname = taskname.substring(0,index);
                    topEightTasks.get(i).setTaskname(taskname);
                }

                // 将身份证和户口综合的 业务量 汇总到 户政综合
                if (taskname.contains("户政综合")) {
                    temp = i;
                } else if (taskname.contains("身份证")) {
                    numTemp += topEightTasks.get(i).getNum();//业务总量
                    winNumTemp += topEightTasks.get(i).getWinNum();//平均窗口业务量
                } else if (taskname.contains("户口综合")) {
                    numTemp += topEightTasks.get(i).getNum();//业务总量
                    winNumTemp += topEightTasks.get(i).getWinNum();//平均窗口业务量
                }
                // 将不动产税务....缩短为 不动产契税
                if (taskname.contains("不动产税务")) {
                    int index = taskname.indexOf("税务");
                    String begin = taskname.substring(0,index);
                    String end = taskname.substring(index+2,taskname.length());
                    topEightTasks.get(i).setTaskname(begin + end);
                }
            }

            // 通过temp下标找到户政综合，并修改业务量
            if (temp != 0) {
                topEightTasks.get(temp).setNum(numTemp);
                topEightTasks.get(temp).setWinNum(winNumTemp);
            } else {
                topEightTasks.add(new TopEightTask("户政综合",numTemp,winNumTemp));
            }

            //删去领证业务，身份证，户口综合
            Iterator<TopEightTask> iterator = topEightTasks.iterator();
            while (iterator.hasNext()) {
                String taskname = iterator.next().getTaskname();
                if (taskname.contains("领证")) {
                    iterator.remove();
                } else if (taskname.contains("身份证")) {
                    iterator.remove();
                } else if (taskname.contains("户口综合")) {
                    iterator.remove();
                }
            }

            //对业务总量进行排序
            topEightTasks.sort(new Comparator<TopEightTask>() {
                @Override
                public int compare(TopEightTask o1, TopEightTask o2) {
                    return o2.getNum()-o1.getNum();
                }
            });

            //获取前8个
            for (int i=0; i<8; i++) {
                TopEightTask topEightTask = topEightTasks.get(i);
                returnEightTasks.add(topEightTask);
            }
            return returnEightTasks;
        }
    }

    /**
     * 16.近30天业务量统计
     * @return
     */
    //16.1 近30天现场取号数
    @Override
    @DS("hqueue")
    public Integer getXCNumMouthTotal(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 6055;
        } else {
            return queueMapper.getXCNumMouthTotal(start,end);
        }
    }
    //16.2 近30天预约取号数
    @Override
    @DS("hqueue")
    public Integer getYYNumMouthTotal(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 4381;
        } else {
            return queueMapper.getYYNumMouthTotal(start,end);
        }
    }
    //16.3 近30天预约数
    @Override
    @DS("hqueue")
    public Integer getOrderMouthTotal(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 4753;
        } else {
            return queueMapper.getOrderMouthTotal(start,end);
        }
    }
    //16.4 近30天取号总数
    @Override
    @DS("hqueue")
    public Integer getNumMouthTotal(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 10436;
        } else {
            return queueMapper.getNumMouthTotal(start,end);
        }
    }

    //16.5 近30天微信取号数
    @Override
    @DS("hqueue")
    public Integer getWXNumMouthTotal(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 1230;
        } else {
            return queueMapper.getWXNumMouthTotal(start,end);
        }
    }
    //16.6 近30天收件总数
    @Override
    @DS("hqueue")
    public Integer getMouthTotalDeal(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 5783;
        } else {
            return queueMapper.getMouthTotalDeal(start,end);
        }
    }
    //16.7 近30天发证总数
    @Override
    @DS("hqueue")
    public Integer getMouthTotalSend(String start, String end) {
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            return 1884;
        } else {
            //return queueMapper.getMouthTotalSend(start,end);
            //return 0;
            return queueMapper.getMouthTotalSendByComName(start,end);
        }
    }
    //最近30天的每日收件量
    /**
     *以当前时间的最近30天的受理量
     * @return
     */
    @Override
    public Map<String, Integer> lateThirty(int num) {
        int notWorkDay = DateUtil.getNotWorkDay(num);
        String pattern = "yyyy-MM-dd HH:mm:ss";
        Map<String,Integer> map = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            /**
             *  随机返回默认数据类型
             * 1.返回300以内的随机数据
             * 2.以起始数据开始每天增加一定数值
             */
            Random random = new Random();
            for (int i = 30; i > 0; i--) {
                map.put("" + i + "", random.nextInt(80)+200);
            }
            return map;
        } else {
            //30天每个工作日办件量
            /*for (int i = 30+notWorkDay; i>0; i--){
                SimpleDateFormat sdf = new SimpleDateFormat(pattern);
                Date startDate = DateUtil.getLateWorkDay(i, 0, 0, 0);
                Date endDate = DateUtil.getLateWorkDay(i, 23, 59, 59);
                if (startDate != null && endDate != null){
                    String start = sdf.format(startDate);
                    String end = sdf.format(endDate);
                    int num1 = getMouthTotalDeal(start,end);
                    map.put(new SimpleDateFormat("yyyy-MM-dd").format(startDate),num1);
                }
            }*/
            //List<String> workDays = DateUtil.near30WorkDay();
            List<String> workDays = DateUtil.getThirtyDate();
            for (int i = 0; i < workDays.size(); i++) {
                String start = workDays.get(i) + " 00:00:00";
                String end = workDays.get(i) + " 23:59:59";
                int num1 = getMouthTotalDeal(start,end);
                map.put(workDays.get(i),num1);
            }
            return  map;
        }
    }
    //最近30天的每日发证量
    /**
     * 近 30天的发证量
     * @return
     */
    @Override
    public Map<String, Integer> lateThirtySend(int num) {
        int notWorkDay = DateUtil.getNotWorkDay(num);
        String pattern = "yyyy-MM-dd HH:mm:ss";
        Map<String,Integer> map = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            /**
             *  随机返回默认数据类型
             * 1.返回300以内的随机数据
             * 2.以起始数据开始每天增加一定数值
             */
            Random random = new Random();
            for (int i = 30; i > 0; i--) {
                map.put("" + i + "", random.nextInt(50)+50);
            }
            return map;
        } else {
            //30天每个工作日的发证量
            /*for (int i = 30+notWorkDay; i>0; i--){
                SimpleDateFormat sdf=new SimpleDateFormat(pattern);
                Date startDate = DateUtil.getLateWorkDay(i, 0, 0, 0);
                Date endDate = DateUtil.getLateWorkDay(i, 23, 59, 59);
                if (startDate != null && endDate != null){
                    String start = sdf.format(startDate);
                    String end = sdf.format(endDate);
                    int num1 = getMouthTotalSend(start,end);
                    map.put(new SimpleDateFormat("yyyy-MM-dd").format(startDate),num1);
                }
            }*/
            //List<String> workDays = DateUtil.near30WorkDay();
            List<String> workDays = DateUtil.getThirtyDate();
            for (int i = 0; i < workDays.size(); i++) {
                String start = workDays.get(i) + " 00:00:00";
                String end = workDays.get(i) + " 23:59:59";
                int num1 = getMouthTotalSend(start,end);
                map.put(workDays.get(i),num1);
            }
            return  map;
        }
    }
    //事项同源统计，是否本地化事项
    @Override
    @DS("shoujian")
    public Map<String, String> localRate() {
        Map<String,String> returnMap = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            returnMap.put("onlineCount","213");//上线事项总数
            returnMap.put("localCount","5");//本地化事项总数
            returnMap.put("nonlocalRate","98%");//非本地化比例
            returnMap.put("localRate","2%");//本地化比例
            return returnMap;
        } else {
            Integer localCount = statisticsMapper.localCount();
            Integer nonlocalCount = statisticsMapper.nonlocalCount();
            Integer onlineCount = statisticsMapper.onlineCount();
            double localRate = new BigDecimal(CalculateUtil.evalRate(onlineCount, localCount)).multiply(new BigDecimal(100))
                    .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
            double nonlocalRate = new BigDecimal(CalculateUtil.evalRate(onlineCount, nonlocalCount)).multiply(new BigDecimal(100))
                    .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
            returnMap.put("onlineCount", String.valueOf(onlineCount));
            returnMap.put("localCount", String.valueOf(localCount));
            returnMap.put("localRate", String.valueOf(localRate));
            returnMap.put("nonlocalRate", String.valueOf(nonlocalRate));
            return returnMap;
        }
    }
    //近30天退件率
    @Override
    public Map<String, String> sendBackRate() throws ParseException {
        Map<String,String> returnMap = new ConcurrentHashMap<>();
        // 是否打开模拟数据，0否，1是
        String openSimulateData = systemParamService.getValueByName("openSimulateData");
        //logger.info("是否打开模拟数据，0否，1是，openSimulateData=" + openSimulateData);
        if (StringUtils.isNotBlank(openSimulateData) && "1".equals(openSimulateData)) {
            returnMap.put("receiveMouthCount","5783");//收件量
            returnMap.put("sendBackCount","116");//退件量
            returnMap.put("receiveRate","98%");//未退件率
            returnMap.put("sendBackRate","2%");//退件率
            return returnMap;
        } else {
            List<String> workDays = DateUtil.getThirtyDate();
            String start = workDays.get(0) + " 00:00:00";
            String end = workDays.get(workDays.size() - 1) + " 23:59:59";
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            Integer sendBackCount = statisticsMapper.sendBackCount(sdf.parse(start));
            Integer sendBackCount = 0;
            Integer receiveMouthCount = this.getMouthTotalDeal(start, end);
            double sendBackRate = new BigDecimal(CalculateUtil.evalRate(receiveMouthCount, sendBackCount)).multiply(new BigDecimal(100))
                    .setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
            double receiveRate = 100.00 - sendBackRate;
            returnMap.put("receiveMouthCount", String.valueOf(receiveMouthCount));
            returnMap.put("sendBackCount", String.valueOf(sendBackCount));
            returnMap.put("receiveRate", String.valueOf(receiveRate));
            returnMap.put("sendBackRate", String.valueOf(sendBackRate));
            return returnMap;
        }
    }

}
